<div class="form">
    <?php echo validation_errors(); ?>
    
    <?php echo form_open($action); ?>
        <div id="tabs">
            <ul>
                <li><a href="#tabs-1">基本信息</a></li>
                <li><a href="#tabs-2">收费信息</a></li>
                <li><a href="#tabs-3">联系信息</a></li>
            </ul>
            <div id="tabs-1">
                <div>
                    <label class="span-4">名称（中文）<span class="required">*</span></label>
                    <input class="text span-17" id="p_name" name="p_name" 
                           value="<?php echo set_value('p_name', $partner['p_name']); ?>" />
                    <div class="clear"></div>
                </div>
                <div>
                    <label class="span-4">名称（英文）</label>
                    <input class="text span-17" id="p_name_en" name="p_name_en" 
                           value="<?php echo set_value('p_name_en', $partner['p_name_en']); ?>" />
                    <div class="clear"></div>
                </div>
                <div>
                    <label class="span-4">地址（中文）<span class="required">*</span></label>
                    <input class="text span-17" id="p_addr" name="p_addr" 
                           value="<?php echo set_value('p_addr', $partner['p_addr']); ?>" />
                    <div class="clear"></div>
                </div>
                <div>
                    <label class="span-4">地址（英文）</label>
                    <input class="text span-17" id="p_addr_en" name="p_addr_en" 
                           value="<?php echo set_value('p_addr_en', $partner['p_addr_en']); ?>" />
                    <div class="clear"></div>
                </div>
                <div>
                    <label class="span-4">名称缩写<span class="required">*</span></label>
                    <input class="text span-5" id="p_name_abbr" name="p_name_abbr" 
                           value="<?php echo set_value('p_name_abbr', $partner['p_name_abbr']); ?>" />
                    <label class="span-4">国家</label>
                    <input class="text span-5" id="p_country" name="p_country" 
                           value="<?php echo set_value('p_country', $partner['p_country']); ?>" />
                    <div class="clear"></div>
                </div>
                <div>
                    <label class="span-4">邮寄地址（中文）<span class="required">*</span></label>
                    <input class="text span-17" id="p_mailing_addr" name="p_mailing_addr" 
                           value="<?php echo set_value('p_mailing_addr', $partner['p_mailing_addr']); ?>" />
                    <div class="clear"></div>
                </div>
                <div>
                    <label class="span-4">邮寄地址（英文）</label>
                    <input class="text span-17" id="p_mailing_addr_en" name="p_mailing_addr_en" 
                           value="<?php echo set_value('p_mailing_addr_en', $partner['p_mailing_addr_en']); ?>" />
                    <div class="clear"></div>
                </div>
            </div>
            <div id="tabs-2">
                <div>
                    <label class="span-3">币种</label>
                    <input class="text span-5" id="p_currency" name="p_currency" 
                           value="<?php echo set_value('p_currency', $partner['p_currency']); ?>" />
                    <div class="clear"></div>
                </div>
                <div>
                    <?php if (isset($fees_html)) echo $fees_html; ?>
                <button type="button" onclick="newFee(this);">新增费用类型</button>
                </div>
            </div>
            <div id="tabs-3">
                <?php if (isset($contacts_html)) echo $contacts_html; ?>
                <button type="button" onclick="newContact(this);">新增联系人</button>
            </div>
        </div>
        <div class="form-actions">
            <input type="submit" class="form-submit" value="保存" />
        </div>
    </form>
</div>
<script>
    $(function() {
        $("#tabs").tabs();
        $("button:not(.adhere)").button();
    });

    function newContact(sender) {
        var element = $('<?php echo $empty_contact_html; ?>');
        element.find("button:not(.adhere)").button();
        $(sender).before(element);
    }
    function delContact(sender) {
        $(sender).parents('fieldset').remove();
    }
    
    function newFee(sender) {
        var element = $('<?php echo $empty_fee_html; ?>');
        element.find("button:not(.adhere)").button();
        $(sender).before(element);
    }
    function delFee(sender) {
        $(sender).parent().remove();
    }
</script>
